package com.zh.zhbootcommon.config.minio;

import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 描述:
 *
 * @author: yanglin
 * @Date: 2021-09-01-14:51
 * @Version: 1.0
 */
@Data
@Component
public class MinioConfig {

    @Autowired
    private MinIoProperties minioProperties;

    @Bean
    public MinioClient getMinioClient() throws InvalidEndpointException, InvalidPortException {
        MinioClient minioClient = new MinioClient(minioProperties.getEndpoint(), minioProperties.getPort(),
                minioProperties.getAccessKey(), minioProperties.getSecretKey(), minioProperties.getSecure());
        return minioClient;
    }
}
